import React,{useState,useContext} from "react";
import {barContext} from "../../contexts";

export default function Select(props) {
    
    const {state,dispatch} = useContext(barContext)

    const valueChange = function(e) {
        dispatch({
            type:'ORDER',
        })
        
    }

    return (
        <label htmlFor="order" >
            排序：
            <select id="order" onChange={valueChange} >
                <option value="0" selected={state.orderValue == 0}>从小到大</option>  
                <option value="1" selected={state.orderValue == 1}>从大到小</option>  
            </select>

        </label>
                
    )
}